package com.utf999.qiangmanger.dao.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Component;

import com.utf999.qiangmanger.dao.AbstractRelationalDBDAO;
import com.utf999.qiangmanger.dao.iface.IStoreUserGroupDAO;
import com.utf999.qiangmanger.entity.orm.StoreUserGroupEntity;
import com.utf999.qiangmanger.exception.BizException;

/**
 * @author yinwenjie
 */
@Component("StoreUserGroupDAOImpl")
public class StoreUserGroupDAOImpl extends AbstractRelationalDBDAO<StoreUserGroupEntity> implements IStoreUserGroupDAO {
	@Override
	protected Class<StoreUserGroupEntity> getEntityClass() {
		return StoreUserGroupEntity.class;
	}

	//TODO 未进行sql优化
	/* (non-Javadoc)
	 * @see com.utf999.qiangmanger.dao.iface.IStoreUserGroupDAO#queryStoregroupByCompanyid(java.lang.String)
	 */
	@Override
	public List<StoreUserGroupEntity> queryStoregroupByCompanyid(String companyid) throws BizException {
		HashMap<String, Object>  condition = new HashMap<String, Object>();
		condition.put("companyid", companyid);
		
		List<StoreUserGroupEntity> groups = this.queryByHqlFile("IStoreUserGroupDAO.queryStoregroupByCompanyid", condition);
		return groups;
	}

	/* (non-Javadoc)
	 * @see com.utf999.qiangmanger.dao.iface.IStoreUserGroupDAO#bindUsergroupMapping(java.lang.String, java.lang.String)
	 */
	@Override
	public void bindUsergroupMapping(String userid, String groupid) throws BizException {
		HashMap<String, Object> condition = new HashMap<String, Object>();
		condition.put("userid", userid);
		condition.put("groupid", groupid);
		
		this.executeSQLFile("IStoreUserGroupDAO.bindUsergroupMapping", condition);
	}

	/* (non-Javadoc)
	 * @see com.utf999.qiangmanger.dao.iface.IStoreUserGroupDAO#unbindUsergroupMapping(java.lang.String, java.lang.String)
	 */
	@Override
	public void unbindUsergroupMapping(String userid, String groupid) throws BizException {
		HashMap<String, Object> condition = new HashMap<String, Object>();
		condition.put("userid", userid);
		condition.put("groupid", groupid);
		
		this.executeSQLFile("IStoreUserGroupDAO.unbindUsergroupMapping", condition);
	}
}
